package com.meixiang.global;

import android.app.Activity;
import android.util.Log;

import com.google.gson.reflect.TypeToken;
import com.lzy.okhttputils.model.HttpParams;
import com.meixiang.entity.EvaluateGradle;
import com.meixiang.http.HttpCallBack;
import com.meixiang.http.HttpUtils;
import com.meixiang.main.MXApplication;
import com.meixiang.util.AbJsonUtil;
import com.meixiang.util.AbStrUtil;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yinsujun  Created at 2016/6/27 18:19
 */
public class GlobalConventionalData {
    /**
     * 获取星级评分规则
     * @param activity
     */
    public static void getEvaluateStart(Activity activity){

        String url=Config.SERVER_URL+"evalStar/getEvalStar";
        HttpUtils.post(url, new HttpParams(), new HttpCallBack(activity) {
            @Override
            public void onSucceed(JSONObject result, String code, String message) {
                if(!AbStrUtil.isEmpty(result.toString())){
//                    List<EvaluateGradle> evaluateGradle= AbJsonUtil.fromJson(result.optJSONArray("evalStars").toString(),new TypeToken<ArrayList<EvaluateGradle>>(){});
                    MXApplication.mApp.saveEvaluateGradle(result.optJSONArray("evalStars").toString());
                    MXApplication.mApp.getEvaluateGradle();
//                    Log.e(this.getClass().getSimpleName(),MXApplication.mApp.getGradleList().toString());

                }
            }

            @Override
            public void onError(String code, String message) {

            }
        });
    }
}
